package com.PVZ.view.canvas;

import com.PVZ.engine.map.GameMap;
import lombok.Getter;
import lombok.Setter;

import javax.swing.*;
import java.awt.*;

/**
 * Created by @Author: kabuda on @Date: 2021/5/26 22:22
 *
 * 背景画布
 */
@Getter
@Setter
public class BackGroundCanvas extends JPanel {
    private Image backgroundImage;
    private Image image;
    private int curPosition = -100;

    public BackGroundCanvas(GameMap gameMap){
        backgroundImage = new ImageIcon(gameMap.getBackGroundSrc()).getImage();
        this.setOpaque(false);
    }

    @Override
    public void paint(Graphics g) {
        super.paint(g);
        g.drawImage(backgroundImage, curPosition, 0, null);
    }
}
